package GUI;

import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

import javax.swing.JFormattedTextField;
import javax.swing.JTextField;
import javax.swing.text.MaskFormatter;

public class VKFormattedTextField extends JFormattedTextField implements FocusListener {
	
	private MainMenu mainMenu;
	
	public VKFormattedTextField(final MainMenu mm, MaskFormatter mf)
	{
		super(mf);
		mainMenu=mm;
		this.addFocusListener( this);
		
	}
	
	
	

	@Override
	public void focusGained(FocusEvent arg0) {
		JFormattedTextField text=((JFormattedTextField)arg0.getSource());
		mainMenu.keyboard.T.position=text.getCaretPosition();
		mainMenu.keyboard.T.formattedTextField=text;				
		mainMenu.keyBoardDigits.T.position=text.getCaretPosition();
		System.out.println("position = " + text.getCaretPosition());
		mainMenu.keyBoardDigits.T.formattedTextField=text;
		mainMenu.keyBoardDigits.T.KBSwitch=1;
		mainMenu.keyboard.T.KBSwitch=1;
		
	}

	@Override
	public void focusLost(FocusEvent arg0) {
		//mainMenu.keyboard.T.TextField=null;
		
	}

}

